using System;
using System.Runtime.CompilerServices;
namespace wang.Net
{
	internal class HttpSetCookie
	{
		public string name;
		public string value;
		public string path;
		public string domain;
		[MethodImpl(MethodImplOptions.NoInlining)]
		public HttpSetCookie(string n, string v, string d, string p)
		{
			this.name = n;
			this.value = v;
			this.domain = d;
			this.path = p;
		}
		[MethodImpl(MethodImplOptions.NoInlining)]
		public HttpSetCookie(string cookie, Uri url)
		{
			string[] array = cookie.Split(new string[]
			{
				";"
			}, StringSplitOptions.RemoveEmptyEntries);
			for (int i = 0; i < array.Length; i++)
			{
				if (!string.IsNullOrEmpty(array[i]))
				{
					int num = array[i].IndexOf('=');
					string text = "";
					string text2;
					if (num >= 0)
					{
						text2 = array[i].Substring(0, num).Trim();
						text = array[i].Substring(num + 1);
					}
					else
					{
						text2 = array[i].Trim();
					}
					string a;
					if ((a = text2.ToLower()) != null)
					{
						if (a == "path")
						{
							this.path = text;
							goto IL_D6;
						}
						if (a == "domain")
						{
							this.domain = text;
							goto IL_D6;
						}
						if (a == "expires")
						{
							goto IL_D6;
						}
					}
					if (i == 0)
					{
						this.name = text2;
						this.value = text;
					}
				}
				IL_D6:;
			}
			if (string.IsNullOrEmpty(this.domain))
			{
				this.domain = url.Host;
			}
		}
		[MethodImpl(MethodImplOptions.NoInlining)]
		public bool HasCookie(Uri url)
		{
			return (url.Host.IndexOf(this.domain) >= 0 || !(string.Format(".{0}", url.Host.ToLower()) != this.domain.ToLower())) && (!string.IsNullOrEmpty(this.path) || !(this.path != "/") || url.AbsoluteUri.IndexOf(string.Format("{0}{1}", this.domain, this.path)) >= 0);
		}
	}
}
